Skip to content

pkg: Switch from @js-temporal/polyfill to temporal-polyfill#3815

Merged
ntucker merged 1 commit intomasterfrom
temporal-polyfill-native
Mar 24, 2026
Merged

pkg: Switch from @js-temporal/polyfill to temporal-polyfill#3815
ntucker merged 1 commit intomasterfrom
temporal-polyfill-native

Conversation

@ntucker
Copy link
Collaborator

@ntucker ntucker commented Mar 24, 2026

Motivation

@js-temporal/polyfill is 51.9 KB gzip and relies on JSBI internally. temporal-polyfill (by FullCalendar's arshaw) is only 19.8 KB gzip with the same spec compliance (Mar 2025), no BigInt dependency, and supports global polyfill mode. With native Temporal now shipping in Chrome 144+, Firefox 139+, and Edge 144+, the website can use the native implementation when available while still delivering the polyfill for Safari and older browsers.

Solution

  • Swap dependency: Replace @js-temporal/polyfilltemporal-polyfill across root, website, packages (devDeps), and github-app example (7 package.json files)
  • Native-first shim: New website/src/components/Playground/temporal.ts checks globalThis.Temporal at init — uses native API on supporting browsers, falls back to polyfill otherwise. Polyfill is still bundled (static import) for zero-latency fallback
  • Playground scope: PreviewWithScope.tsx imports from the shim instead of the polyfill directly
  • Monaco types: Updated module declarations and copied types from temporal-spec (the actual type source) instead of the re-exporting temporal-polyfill/index.d.ts
  • Import updates: 23 source files, 3 doc/blog files, copywebsitetypes.sh script all updated from @js-temporal/polyfilltemporal-polyfill

Open questions

N/A

Made with Cursor


Note

Medium Risk
Medium risk because it replaces a foundational date/time polyfill across packages, examples, tests, and the website playground (including Monaco type wiring), which could cause subtle runtime or typing regressions despite being mostly import/dependency changes.

Overview
Replaces @js-temporal/polyfill with temporal-polyfill across the repo (root/workspace packages, website, docs, tests, and the GitHub app example), updating all Temporal/Intl imports and lockfile entries accordingly.

Updates the website Playground to be native-first by introducing a small temporal shim that prefers globalThis.Temporal when available, and adjusts Monaco/editor type loading to declare the new module name and copy Temporal types from temporal-spec instead of the old polyfill’s .d.ts.

Written by Cursor Bugbot for commit 177b9f7. This will update automatically on new commits. Configure here.

temporal-polyfill is 60% smaller (19.8 KB vs 51.9 KB gzip), same spec
compliance, and avoids JSBI. Website playground now uses native Temporal
API when available (Chrome/Firefox/Edge) with polyfill fallback for
Safari and older browsers.

Made-with: Cursor
@vercel
Copy link

vercel bot commented Mar 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs-site Ready Ready Preview, Comment Mar 24, 2026 9:41pm

@changeset-bot
Copy link

changeset-bot bot commented Mar 24, 2026

⚠️ No Changeset found

Latest commit: 177b9f7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Contributor

Size Change: 0 B

Total Size: 80.5 kB

ℹ️ View Unchanged
Filename Size
examples/test-bundlesize/dist/App.js 3.18 kB
examples/test-bundlesize/dist/polyfill.js 307 B
examples/test-bundlesize/dist/rdcClient.js 10.2 kB
examples/test-bundlesize/dist/rdcEndpoint.js 6.35 kB
examples/test-bundlesize/dist/react.js 59.7 kB
examples/test-bundlesize/dist/webpack-runtime.js 726 B

compressed-size-action

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark React

Details
Benchmark suite Current: 177b9f7 Previous: e6f05d7 Ratio
data-client: getlist-100 190.49 ops/s (± 4.9%) 173.93 ops/s (± 4.2%) 0.91
data-client: getlist-500 43.38 ops/s (± 8.9%) 45.05 ops/s (± 8.3%) 1.04
data-client: update-entity 400 ops/s (± 6.3%) 513.16 ops/s (± 7.1%) 1.28
data-client: update-user 416.67 ops/s (± 8.0%) 454.55 ops/s (± 0.0%) 1.09
data-client: getlist-500-sorted 42.92 ops/s (± 9.2%) 49.75 ops/s (± 1.2%) 1.16
data-client: update-entity-sorted 294.12 ops/s (± 7.5%) 416.67 ops/s (± 0.0%) 1.42
data-client: update-entity-multi-view 344.83 ops/s (± 8.4%) 384.62 ops/s (± 6.1%) 1.12
data-client: list-detail-switch-10 13.02 ops/s (± 8.0%) 13.24 ops/s (± 4.0%) 1.02
data-client: update-user-10000 91.74 ops/s (± 4.9%) 107.53 ops/s (± 4.0%) 1.17
data-client: invalidate-and-resolve 45.05 ops/s (± 5.1%) 50.77 ops/s (± 5.7%) 1.13
data-client: unshift-item 277.78 ops/s (± 3.7%) 307.77 ops/s (± 4.6%) 1.11
data-client: delete-item 454.55 ops/s (± 3.8%) 384.62 ops/s (± 4.7%) 0.85
data-client: move-item 212.77 ops/s (± 5.9%) 232.56 ops/s (± 5.6%) 1.09

This comment was automatically generated by workflow using github-action-benchmark.

@codecov
Copy link

codecov bot commented Mar 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.06%. Comparing base (e6f05d7) to head (177b9f7).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3815   +/-   ##
=======================================
  Coverage   98.06%   98.06%           
=======================================
  Files         151      151           
  Lines        2843     2843           
  Branches      556      556           
=======================================
  Hits         2788     2788           
  Misses         11       11           
  Partials       44       44           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Details
Benchmark suite Current: 177b9f7 Previous: eeda4b5 Ratio
normalizeLong 437 ops/sec (±1.34%) 447 ops/sec (±2.48%) 1.02
normalizeLong Values 401 ops/sec (±0.66%) 419 ops/sec (±0.15%) 1.04
denormalizeLong 274 ops/sec (±3.24%) 295 ops/sec (±2.45%) 1.08
denormalizeLong Values 266 ops/sec (±2.43%) 268 ops/sec (±1.83%) 1.01
denormalizeLong donotcache 1031 ops/sec (±0.19%) 1065 ops/sec (±0.33%) 1.03
denormalizeLong Values donotcache 771 ops/sec (±0.19%) 772 ops/sec (±0.19%) 1.00
denormalizeShort donotcache 500x 1587 ops/sec (±0.11%) 1576 ops/sec (±0.10%) 0.99
denormalizeShort 500x 834 ops/sec (±2.33%) 1092 ops/sec (±0.12%) 1.31
denormalizeShort 500x withCache 6086 ops/sec (±0.30%) 6086 ops/sec (±0.18%) 1
queryShort 500x withCache 2493 ops/sec (±0.08%) 2738 ops/sec (±0.56%) 1.10
buildQueryKey All 54417 ops/sec (±0.26%) 54218 ops/sec (±0.89%) 1.00
query All withCache 7955 ops/sec (±0.19%) 6144 ops/sec (±0.65%) 0.77
denormalizeLong with mixin Entity 274 ops/sec (±2.40%) 361 ops/sec (±0.20%) 1.32
denormalizeLong withCache 6265 ops/sec (±0.12%) 7089 ops/sec (±0.24%) 1.13
denormalizeLong Values withCache 5133 ops/sec (±0.19%) 5084 ops/sec (±0.19%) 0.99
denormalizeLong All withCache 7673 ops/sec (±0.16%) 6032 ops/sec (±0.91%) 0.79
denormalizeLong Query-sorted withCache 8002 ops/sec (±0.16%) 6263 ops/sec (±0.24%) 0.78
denormalizeLongAndShort withEntityCacheOnly 1704 ops/sec (±0.20%) 1739 ops/sec (±0.16%) 1.02
getResponse 4648 ops/sec (±0.58%) 4595 ops/sec (±0.46%) 0.99
getResponse (null) 10101497 ops/sec (±0.86%) 10284649 ops/sec (±0.91%) 1.02
getResponse (clear cache) 263 ops/sec (±2.22%) 344 ops/sec (±0.41%) 1.31
getSmallResponse 3328 ops/sec (±0.10%) 3299 ops/sec (±0.67%) 0.99
getSmallInferredResponse 2559 ops/sec (±0.08%) 2472 ops/sec (±0.64%) 0.97
getResponse Collection 4601 ops/sec (±0.44%) 4527 ops/sec (±0.33%) 0.98
get Collection 4574 ops/sec (±0.42%) 4591 ops/sec (±0.17%) 1.00
get Query-sorted 5243 ops/sec (±0.20%) 4650 ops/sec (±0.29%) 0.89
setLong 451 ops/sec (±0.24%) 463 ops/sec (±0.18%) 1.03
setLongWithMerge 258 ops/sec (±0.21%) 262 ops/sec (±0.17%) 1.02
setLongWithSimpleMerge 272 ops/sec (±0.21%) 278 ops/sec (±0.13%) 1.02
setSmallResponse 500x 953 ops/sec (±0.09%) 958 ops/sec (±0.28%) 1.01

This comment was automatically generated by workflow using github-action-benchmark.

@ntucker ntucker merged commit b3b1b61 into master Mar 24, 2026
28 checks passed
@ntucker ntucker deleted the temporal-polyfill-native branch March 24, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant